package com.library.service;

import com.library.bean.Admin;
import com.library.dao.AdminBorrowDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

/**
 * author  weizhihao
 * Created by 2020-03-22-14:57
 */
@Service
public class AdminBorrowService {

    @Autowired
    private AdminBorrowDao adminBorrowDao;

    public boolean addAdmainBorrow(Admin admin) {
        return adminBorrowDao.addAdmainBorrow(admin) > 0;
    }

    public boolean deleteAdminBorrow( long admin_id) {
        return adminBorrowDao.deleteAdminBorrow(admin_id) > 0;
    }

    public boolean updateAdminBorrowMessage( Admin admin) {
        return adminBorrowDao.updateAdminBorrowMessage(admin) > 0;
    }

    /*借阅管理员权限变为管理员权限*/
    public boolean updatePowerToAdmin( long admin_id){
        return  adminBorrowDao.updatePowerToAdmin(admin_id) > 0;
    }

    /*管理员权限变为借阅管理员权限*/
    public boolean updatePowerToAdminBorrow( long admin_id){
        return  adminBorrowDao.updatePowerToAdminBorrow(admin_id) > 0;
    }

    public ArrayList<Admin> findAllAdmainBorrow() {
        return adminBorrowDao.findAllAdmainBorrow();
    }

    public Admin findAdmainBorrowById( long admin_id) {
        return adminBorrowDao.findAdmainBorrowById(admin_id);
    }

    public boolean resetAdminBorrowPassword( long admin_id,  String password){
        return adminBorrowDao.resetAdminBorrowPassword(admin_id, password)>0;
    }

    public String getAdminBorrowPassword( long admin_id){
        return adminBorrowDao.getAdminBorrowPassword(admin_id);
    }
}
